//
//  TelephoneAPI.swift
//  zhonglb_iOS
//
//  Created by lxm on 2021/12/7.
//

import Foundation
import Alamofire

enum TelephoneAPI{
    /// 获取充值面值套餐列表
    case meal_list(_ params : [String : Any])
    // 获取手机号的信息
    case phone_info(params : [String : Any])
    // 充值说明
    case charge_intro
    // 话费订单充值
    case charge(params : [String : Any])
    // 充值记录
    case charge_record(params : [String : Any])
    // 创建订单
    case create_order(_ params : [String : Any])
    
}

extension TelephoneAPI: ZMApiProvider {
    func urlAndMthodAndParam() -> (url: String, method: ZMHTTPMethod, params: [String : Any], body: Bool) {
        switch self {
        case .meal_list(let pa):
            return ("/api/front/recharge/listDenomination", .get, pa, false)
        case .phone_info(let pa):
            return ("/mallrest/prepaidRefill/getPhoneInfo", .get, pa, false)
        case .charge_intro:
            return ("/mallrest/prepaidRefill/getExplainParameter", .get, [:], false)
        case .charge(let pa):
            return ("/mallrest/prepaidRefill/payBill", .post, pa, false)
        case .charge_record(let pa):
            return ("/api/front/recharge/listOrder", .get, pa, false)
        case .create_order(let pa):
            return ("/api/front/recharge/create", .post, pa, true)
        }
    }
    
    func BaseUrl() -> String {
        return baseUrl
    }
    
    
    func HTTPHeader() -> ZMHTTPHeaders? {
        return AppHelper.reqeustHeader()
    }
    
    func UpLoadData() -> [Data]? {
        return nil
    }
    
    func singleRequest() -> Bool {
        switch self {
        case .phone_info:
            return true
        default:
            return false
        }
    }
}
